fix(terraphim-agent): resolve role shortnames, fix remote thesaurus, add LLM proxy fallback#726
Open
AlexMikhalev wants to merge 2 commits intomainfrom
Open
fix(terraphim-agent): resolve role shortnames, fix remote thesaurus, add LLM proxy fallback#726AlexMikhalev wants to merge 2 commits intomainfrom
AlexMikhalev wants to merge 2 commits intomainfrom
Conversation
added 2 commits
March 26, 2026 09:40
- Resolve conflicts in learnings/mod.rs (kept necessary exports) - Resolve conflicts in main.rs (removed unused imports) - Fix formatting with cargo fmt - Clean up unused imports per clippy warnings All pre-commit checks pass: - Formatting: clean - Clippy: no warnings - Build: successful - Tests: 148 passed Note: Test fixtures contain example AWS keys for testing secret redaction
…add LLM proxy fallback - Add resolve_role() to TuiService and ApiClient to resolve role shortnames via find_role_by_name_or_shortname() - Fix remote thesaurus loading - read_url() was never called for Remote URLs - Add parse_thesaurus_json() to support both new Thesaurus format and legacy flat format - Add local KG fallback when remote automata_path fails - Add LLM fallback chain: Proxy -> Ollama (when proxy disabled) - Create separate 'proxy' feature in terraphim_service, llm_router depends on it - Make 'dirs' crate non-optional (was used in always-compiled modules) - Update tests to handle proxy connection errors gracefully
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes several issues in the terraphim-agent crate to bring it to a working state:
Bug Fixes
Role shortname resolution -
--roleflag in CLI and REPL was passing values directly toRoleName::new()instead of resolving viafind_role_by_name_or_shortname(). Addedresolve_role()methods toTuiServiceandApiClientto properly resolve role shortnames.Remote thesaurus loading -
read_url()function was implemented but never called for remote URLs. TheRemote(_)branch returned a hardcoded error instead of fetching the data.Thesaurus format mismatch - Remote S3 file uses legacy flat format
{"term": {"id": N, "nterm": "..."}}but code expectedThesaurusformat{"name": "...", "data": {...}}. Addedparse_thesaurus_json()helper to support both formats.Local KG fallback - Added fallback to local knowledge graph when remote
automata_pathfails.LLM fallback chain - Added proper fallback chain: Proxy → Ollama (when proxy disabled) for chat functionality when no explicit LLM config exists.
Features
Code Quality
Separate 'proxy' feature - Created separate
proxyfeature in terraphim_service, madellm_routerdepend on it for cleaner feature gating.Non-optional 'dirs' crate - Made
dirscrate non-optional since it's used in always-compiled modules (onboarding, learnings).Testing
All tests pass:
selected_role_tests: 8/8 passingFiles Changed
crates/terraphim_agent/src/service.rs- Addedresolve_role()to TuiServicecrates/terraphim_agent/src/client.rs- Addedresolve_role()for server modecrates/terraphim_agent/src/main.rs- Updated all CLI subcommands to useresolve_role()crates/terraphim_agent/src/repl/handler.rs- Updated REPL search to resolve shortnamescrates/terraphim_agent/Cargo.toml- Madedirsnon-optionalcrates/terraphim_automata/src/lib.rs- Fixed remote loading, added legacy format parsingcrates/terraphim_config/src/lib.rs- Added local KG fallback, added default LLM config to rolescrates/terraphim_service/src/llm.rs- Added proxy fallback, reorganized fallback chaincrates/terraphim_service/src/llm/proxy_client.rs- Improved error messagecrates/terraphim_service/Cargo.toml- Addedproxyfeaturecrates/terraphim_agent/tests/selected_role_tests.rs- Updated test assertions